using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Gestion_Comercial._2_Logica_de_Negocio;

namespace Gestion_Comercial
{
    public partial class Site1 : System.Web.UI.MasterPage
    {
        public ONComercial UsuarioActivo
        {
            get 
            {
                if (Request.IsAuthenticated == false)
                    return new ONComercial();

                //ONComercial _comercial = Session["usuarioActivo"];

                string _usuarioID = HttpContext.Current.User.Identity.Name;
                ONComercial _comercial = ONComercial.CrearComercial(_usuarioID);
                return _comercial;
            }
        }
        public void AsignarParametrosParaBuscarClientesDeComercialEnMaster(object  sender, ObjectDataSourceSelectingEventArgs e)
        {
            e.InputParameters["pUsuarioActual"] = HttpContext.Current.User.Identity.Name;
            string _rol = ""; //verifico si pertenece al rol de gerentes
            if (HttpContext.Current.User.IsInRole(ConfigurationSettings.AppSettings["GerenteRol"]) == true)
                _rol = ConfigurationSettings.AppSettings["GerenteRol"];
            e.InputParameters["pRolActual"] = _rol;
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            phCentral.Focus();
        }

        protected void phCentral_Load(object sender, EventArgs e)
        {
            
        }

        protected void lblNombre_Load(object sender, EventArgs e)
        {
            ((Label)sender).Text = this.UsuarioActivo.Nombre + " " + this.UsuarioActivo.Apellido;
        }
    }
}
